package com.stay.emoticon;

import android.content.Context;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.Gallery;

public class MyGestureListener extends SimpleOnGestureListener implements OnTouchListener {

	private GestureDetector gDetector;
	private Gallery gallery;

	public MyGestureListener() {
		super();
	}

	public MyGestureListener(Context con) {
		this(con, null, null);
	}

	public MyGestureListener(Context con, GestureDetector gDetector, Gallery gallery) {
		if (null == gDetector) {
			gDetector = new GestureDetector(con, this);
		}
		this.gallery = gallery;
		this.gDetector = gDetector;
	}
	
	@Override
	public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
		return gallery.onFling(e1, e2, velocityX, velocityY);
	}

	@Override
	public boolean onSingleTapConfirmed(MotionEvent e) {
		return super.onSingleTapConfirmed(e);
	}


	@Override
	public boolean onTouch(View v, MotionEvent event) {
//		if (event.getAction() == MotionEvent.ACTION_MOVE) {
//			return gallery.onTouchEvent(event);
//		}else {
			return gDetector.onTouchEvent(event);
//		}
	}

	public GestureDetector getDector() {
		return this.gDetector;
	}
}
